package com.kevin.Code.Tree;

/**
 * @author Vinlee Xiao
 * @Classname SameTree
 * @Description Leetcode 100. 相同的树 简单
 * @Date 2021/10/29 17:24
 * @Version 1.0
 */
public class SameTree {

    /**
     * @param p
     * @param q
     * @return
     */
    public boolean isSameTree(TreeNode p, TreeNode q) {

        //两个结点都为空
        if (p == null && q == null) {
            return true;
        }//一个为空，另外一个不为空
        else if (p == null || q == null) {
            return false;
        } else if (p.val != q.val) {
            return false;
        } else {
            return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
        }


    }


}
